package DAIBANJICHENG;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.alibaba.fastjson.JSONObject;

public class Create_Db {

        public static void main(String[] args) throws IOException {

                long timestamp = System.currentTimeMillis();
                System.out.println(timestamp);

                Date date = new Date();
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
                String yyyymmdd = sdf.format(date);
                System.out.println(yyyymmdd);



                String serverURL = "http://oa.maxwell-gp.com.cn:8090/rest/ofs/ReceiveRequestInfoByJson";
                StringBuffer sbf = new StringBuffer();
                String strRead = null;
                URL url = new URL(serverURL);
                HttpURLConnection connection = (HttpURLConnection)url.openConnection();
                connection.setRequestMethod("POST");//请求post方式
                connection.setDoInput(true);
                connection.setDoOutput(true);
                //header内的的参数在这里set。||connection.setRequestProperty("健, "值");
                connection.setRequestProperty("Content-Type", "application/json");
                connection.setRequestProperty("accept", "*/*");
                connection.setRequestProperty("connection", "Keep-Alive");

                connection.connect();
                OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream(),"UTF-8");
                //body参数在这里put到JSONObject中
                JSONObject parm = new JSONObject();
                parm.put("syscode","Ecology9");
                parm.put("flowid","1");
                parm.put("requestname","FC测试20240705002");
                parm.put("workflowname","FC测试");
                parm.put("nodename","测试节点");
                parm.put("pcurl","http://fzdsb.maxwell-gp.com.cn:8880/pandian");
                parm.put("appurl","http://fzdsb.maxwell-gp.com.cn:8880/pandian");
                parm.put("creator","MW17060100679");
                parm.put("createdatetime","2024-12-24 09:38:56");
                parm.put("receiver","MW17060100679");
                parm.put("receivedatetime",yyyymmdd);
                parm.put("isremark","0");
                parm.put("viewtype","0");
                parm.put("receivets",String.valueOf(timestamp));


                writer.write(parm.toString());
                writer.flush();
                InputStream is = connection.getInputStream();
                BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
                while ((strRead = reader.readLine()) != null) {
                        sbf.append(strRead);
                }
                reader.close();
                connection.disconnect();
                String results = sbf.toString();
                System.out.println(results);


        }

}
